package com.ithiema.reggie.common;

/**
 * 基于ThreadLocal封装工具类，用户保存和获取当前登录用户id
 *
 * @author wangxiao
 * @since 2022/11/2 11:34
 */
public class BaseContext {
    private static final ThreadLocal<Long> THREAD_LOCAL_USER_ID = new ThreadLocal<>();

    /*
    设置当前用户登录ID
     */
    public static void setCurrentUserId(Long currentUserId) {
//        设置值
        THREAD_LOCAL_USER_ID.set(currentUserId);
    }

    /*
    获取当前登录用户id
     */
    public static Long getCurrentUserId() {
        return THREAD_LOCAL_USER_ID.get();
    }
}
